<?php
/**
 * $Author: BEESCMS $
 * ============================================================================
 * 网站地址: http://www.beescms.com
 * 您只能在不用于商业目的的前提下对程序代码进行修改和使用；
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/

define('IN_CMS','true');
include('init.php');
$action=isset($_REQUEST['action'])?fl_html(fl_value($_REQUEST['action'])):'video_list';

$lang=isset($_REQUEST['lang'])?fl_html(fl_value($_REQUEST['lang'])):get_lang_main();


if($action=='add'){
    //$sql="select*from ".DB_PRE."video where 1";
	//$rel=$mysql->fetch_asc($sql);
	include('template/add_video.html');
}
//添加视频
elseif($action=='add_video_info'){
	$name=$_POST['video_name'];
	$content=$_POST['video_content'];
	$price =$_POST['video_price'];
	$nurl =$_POST['video_nurl'];
	$yurl =$_POST['video_yurl'];

	$video_author=$_POST['video_author'];
	$video_time =$_POST['video_time'];
	$video_days =$_POST['video_days'];
	$video_shihe =$_POST['video_shihe'];
	$pic =$_POST['pic'];
	$index=$_POST['index']?$_POST['index']:0;
	$addtime=time();

	$sql="insert into ".DB_PRE."video  (video_name,video_nurl,video_yurl,video_content,video_price,video_addtime,author,video_time,video_days,video_shihe,pic,`index`) values ('".$name."','".$nurl."','".$yurl."','".$content."','".$price."','".$addtime."','{$video_author}','{$video_time}','{$video_days}','{$video_shihe}','{$pic}',{$index})";
	if($mysql->query($sql))
	{
	msg('添加成功','?action=add');	
	}
	else{
		msg('添加失败','?action=add');	
	}
}
//处理配置
elseif($action=='updatevideo'){
$name=$_POST['video_name'];
	$content=$_POST['video_content'];
	$price =$_POST['video_price'];
	$nurl =$_POST['video_nurl'];
	$yurl =$_POST['video_yurl'];
	//print_r($price);die;
	$author=$_POST['author'];
	
	$video_days =$_POST['video_days'];
	$video_shihe =$_POST['video_shihe'];
	$pic =$_POST['pic'];
	$index=$_POST['index']?$_POST['index']:0;
	//print_R($_POST);die;
	$updatetime=time();
	$video_price=intval($_POST['video_price']);

	$sql="update ".DB_PRE."video set video_name='{$name}',video_nurl='{$nurl}',video_yurl='{$yurl}',video_price='{$price}',video_content='{$content}',  author='{$author}',video_days={$video_days},video_shihe='{$video_shihe}',pic='{$pic}',video_uptime={$updatetime},`index`={$index} where video_id=".$_POST['video_id'];
	//echo $price,$sql;die;
	$mysql->query($sql);
	msg('更新成功','?action=video_list');	
}
//留言列表
elseif($action=='video_list'){
	include('template/admin_video_list.html');
}
elseif($action=='order'){
	include('template/admin_order_list.html');
}

elseif($action=='reply'){
	$id=intval($_REQUEST['id']);
	if(empty($id)){die("<script type=\"text/javascript\">alert('参数发生错误，请重新操作');history.go(-1);</script>");}
	$sql="select*from ".DB_PRE."video where video_id=".$id;
	$rel=$mysql->fetch_asc($sql);
	
	
	include('template/admin_video_reply.html');
}

//删除单个删除
elseif($action=='del'){
	$id=$_GET['id'];
	if(empty($id)){die("<script type=\"text/javascript\">alert('参数发生错误，请重新操作');history.go(-1);</script>");}
	$sql="delete from ".DB_PRE."video where video_id=".$id;
	$mysql->query($sql);
	msg('删除完成','?lang='.$lang);
}
//删除多选
elseif($action=='del_all'){
	$id=$_POST['all'];
	if(empty($id)){msg('请选择需要删除的内容','?lang='.$lang);}
	foreach($id as $k=>$v){
		$sql="delete from ".DB_PRE."video where video_id=".$v;
		$mysql->query($sql);
	}
	msg("所选内容已经删除",'?lang='.$lang);
}
elseif($action=='delorder'){
	$id=$_GET['id'];
	if(empty($id)){die("<script type=\"text/javascript\">alert('参数发生错误，请重新操作');history.go(-1);</script>");}
	$sql="delete from ".DB_PRE."video_order where id=".$id;
	$mysql->query($sql);
	msg('删除完成','?lang='.$lang);
}
//删除多选
elseif($action=='del_allorder'){
	$id=$_POST['all'];
	if(empty($id)){msg('请选择需要删除的内容','?lang='.$lang);}
	foreach($id as $k=>$v){
		$sql="delete from ".DB_PRE."video_order where id=".$v;
		$mysql->query($sql);
	}
	msg("所选内容已经删除",'?lang='.$lang);
}
?>
